package com.itheima.reggie.web.controller;

import com.itheima.reggie.config.common.R;
import com.itheima.reggie.entity.Order;
import com.itheima.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单
 * @author BaiXin
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 用户下单
     * @param order
     * @return
     */
    @PostMapping("/submit")
    public R<Boolean> submit(@RequestBody Order order){
        //日志记录
        log.info("订单数据：{}",order);

        //调用service
       orderService.submit(order);

        //数据返回
        return R.success(true);
    }
}